/*
 * @Date: 2024-12-19 09:03:52
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2025-02-20 17:04:40
 * @Description: 图表地图配置
 */

import schema from './schema.js'
import * as mapOption from '@hp/config/option/echarts/echarts-map.js'
import * as baseOption from '@hp/config/option/echarts/echarts-base.js'
// import * as tooltipOption from '@hp/config/option/echarts/echarts-tooltip.js'
// import { useDbSource } from '@hp/hooks/useDbSource.js'

// const { loadDataCols } = useDbSource()


export default {
  // 组件
  component: () => import("./ChartMap.vue"),
  // 类型
  type: 'chartmap',
  // 名称
  name: '地图',
  // 图标或图片
  icon: 'pi/chart-map.png',
  // 初始配置
  schema,
  // 大小定位
  layout: {
    i: '',
    x: '',
    y: '',
    w: 55,
    h: 55,
    minW: 24,
    minH: 12,
    maxW: 120,
    // maxH: 35,
    static: false,
  },
  // 配置
  config: [
    {
      config: {
        label: '基础配置'
      },
      children: [
        {
          type: 'input',
          field: 'desc',
          label: '描述',
          compProps: {
          }
        },
        {
          type: 'switch',
          field: 'showHeader',
          label: '显示头部',
          compProps: {
          }
        },
        {
          type: 'select',
          field: 'textAlign',
          label: '标题对齐',
          compProps: {
            options: baseOption.TitleTextAlignOptions,
            getUpConfig ({ schema }) {
              return {
                display: schema.showHeader
              }
            }
          }
        },
        {
          type: 'switch',
          field: 'drillEnabled',
          label: '地图钻取',
          noForm: false,
          compProps: {
            defaultValue: true
          }
        },
        {
          type: 'select',
          field: 'drillLevel',
          label: '钻取级别',
          compProps: {
            options: mapOption.MapDrillLevels,
            clearable: false,
            defaultValue: 'district',
            getUpConfig ({ schema }) {
              return {
                display: schema.drillEnabled
              }
            }
          }
        },
      ]
    },
    {
      config: {
        label: '数据配置'
      },
      children: [
        {
          type: 'input-dbsource',
          field: 'dataSource',
          label: '数据源',
          noForm: false,
          compProps: {
          }
        },
        {
          type: 'select',
          field: 'mapCode',
          label: '地图选择',
          compProps: {
            options: mapOption.MapTypeOptions,
            clearable: true,
          }
        },
      ]
    },
    {
      config: {
        label: '图例配置'
      },
      children: [
        {
          type: 'number',
          field: 'echarts.geo.zoom',
          label: '缩放比例',
          noForm: false,
          compProps: {
            min: 1,
            max: 4,
            step: 0.1,
          }
        },
        {
          type: 'switch',
          field: 'echarts.geo.label.show',
          label: '显示标签',
          noForm: false,
          compProps: {
            defaultValue: true
          }
        },
      ]
    },
    {
      config: {
        label: '视觉映射'
      },
      children: [
        {
          type: 'switch',
          field: 'echarts.visualMap.show',
          label: '启用',
          noForm: false,
          compProps: {
          }
        },
        {
          type: 'number',
          field: 'echarts.visualMap.min',
          label: '最小值',
          noForm: false,
          compProps: {
          }
        },
        {
          type: 'number',
          field: 'echarts.visualMap.max',
          label: '最大值',
          noForm: false,
          compProps: {
          }
        },
        {
          type: 'input',
          field: 'echarts.visualMap.topText',
          label: '顶部文字',
          noForm: false,
          compProps: {
          }
        },
        {
          type: 'input',
          field: 'echarts.visualMap.bottomText',
          label: '底部文字',
          noForm: false,
          compProps: {
          }
        },
        {
          type: 'select',
          field: 'echarts.visualMap.left',
          label: '横向位置',
          noForm: false,
          compProps: {
            options: baseOption.TitleTextAlignOptions
          }
        },
        {
          type: 'select',
          field: 'echarts.visualMap.top',
          label: '纵向位置',
          noForm: false,
          compProps: {
            options: baseOption.VerticalAlignOptions
          }
        },
      ]
    },
    {
      config: {
        label: '提示框设置'
      },
      children: [
        {
          type: 'switch',
          field: 'echarts.tooltip.show',
          label: '是否显示',
          compProps: {
          }
        }
      ]
    },
    {
      config: {
        label: '事件配置'
      },
      children: [
        {
          type: 'event-onclick',
          field: 'onClick',
          label: 'onClick',
          compProps: {
          }
        },
      ]
    }
  ]
}
